import numpy as np
import matplotlib.pyplot as plt

mean = 0
var = 0
eps = 1e-5
slope = 1
bias = 0.1

def normalize(x, mean, var):
    return (x - mean) / np.sqrt(var + eps) * slope + bias

def f(x):
    return x*2

# 绘制图像
x = np.arange(-10, 10, 0.1)
mean = np.mean(f(x))
var = np.var(f(x))
y1 = f(x)
y2 = normalize(f(x), mean, var)
plt.plot(x, y1, color='green')

# 画出x，y点的移动轨迹。
plt.plot(x, y2, color='red')
# title等方法中，也同样支持latex语法。

plt.title("$y=2x$")

plt.show()
 
